//
// Created by 86131 on 2023/12/9.
//
int insert( struct element item, list_pointer ht[] )
{
    int ret, hash_value;
    list_pointer ptr, trail, lead;

    ret = 1;
    hash_value = hash(item.key);
    trail = NULL; lead = ht[hash_value];
    for ( ; lead; trail = lead, lead = lead->next) {
        if (!strcmp(lead->item.key, item.key)) {
            printf("The key is in the table\n");
            ret = 0;
        }
    }
    if (ret) {
        ptr = (list_pointer)malloc(sizeof(struct list));

        ptr->item = item
                ;
        ptr->next = NULL;
        if (trail)

            trail->next = ptr
                    ;
        else

            ht[hash_value] = ptr
                    ;
    }
    return ret;
}